package com.campus_information_portal.dao;

import com.campus_information_portal.entity.Punish;
import com.campus_information_portal.entity.StuPunish;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 处分dao
 *
 * @author
 * @create 2018-06-09 21:12
 **/
public interface PunishDao {

    //按学号查询处分
    @Select("select student.* , punish.* ,academy.* from student,punish,academy " +
            " where " +
            " student.academy_id=academy.academy_id " +
            "AND student.stu_num=#{stuNum} ")
    List<StuPunish> queryPunishByStuNum(@Param("stuNum")Integer stuNum);

    //查询所有处分
    @Select("select student.* , punish.* ,academy.* from student,punish,academy " +
            " where " +
            " student.academy_id=academy.academy_id " +
            " AND student.stu_num=punish.stu_num ")
    List<StuPunish> queryAllPunish();


    //增加处分
    @Insert("insert into punish(punish_id,punish_time,punish_type,stu_num,status) " +
            "values(NULL,#{punishTime},#{punishType},#{stuNum},3)")
    int addPunish(Punish punish);

    //根据punishId删除
    @Delete("delete from punish where punish_id=#{punishId}")
    int deletePunish(@Param("punishId")Integer punishId);

    //根据punishId修改内容
    @Update("update punish set punish_type=#{punishType} where punish_id=#{punishId}")
    int updatePunish(@Param("punishId")Integer punishId,@Param("punishType")String punishType);

    //根据punishId修改状态
    @Update("update punish set status=#{status} where punish_id=#{punishId}")
    int updatePunishStatus(@Param("punishId")Integer punishId,@Param("status")Integer status);
}
